package com.itheima.reggie.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Controller;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @Description:test
 * @Create by: CAt
 * @Date;2021/9/2619:05
 */
@Controller
@Slf4j
public class MyMetaObjecthandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
         log.info("公共字段填充");
         log.info(metaObject.toString());
         metaObject.setValue("createTime", LocalDateTime.now());
         metaObject.setValue("updateTime", LocalDateTime.now());
         metaObject.setValue("createUser",BaseContext.Gettttt());
         metaObject.setValue("updateUser", BaseContext.Gettttt());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", BaseContext.Gettttt());
    }
}
